package com.ruoyi.performance.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.performance.mapper.AssessmentResultMapper;
import com.ruoyi.performance.domain.AssessmentResult;
import com.ruoyi.performance.service.IAssessmentResultService;

/**
 * 教师考核结果Service业务层处理
 *
 * @author eden
 * @date 2023-05-21
 */
@Service
public class AssessmentResultServiceImpl implements IAssessmentResultService {
    @Autowired
    private AssessmentResultMapper assessmentResultMapper;

    /**
     * 查询教师考核结果
     *
     * @param Id 教师考核结果主键
     * @return 教师考核结果
     */
    @Override
    public AssessmentResult selectAssessmentResultById(Long Id) {
        return assessmentResultMapper.selectAssessmentResultById(Id);
    }

    /**
     * 查询教师考核结果列表
     *
     * @param assessmentResult 教师考核结果
     * @return 教师考核结果
     */
    @Override
    public List<AssessmentResult> selectAssessmentResultList(AssessmentResult assessmentResult) {
        return assessmentResultMapper.selectAssessmentResultList(assessmentResult);
    }

    /**
     * 新增教师考核结果
     *
     * @param assessmentResult 教师考核结果
     * @return 结果
     */
    @Override
    public int insertAssessmentResult(AssessmentResult assessmentResult) {
        assessmentResult.setCreateTime(DateUtils.getNowDate());
        return assessmentResultMapper.insertAssessmentResult(assessmentResult);
    }

    /**
     * 修改教师考核结果
     *
     * @param assessmentResult 教师考核结果
     * @return 结果
     */
    @Override
    public int updateAssessmentResult(AssessmentResult assessmentResult) {
        return assessmentResultMapper.updateAssessmentResult(assessmentResult);
    }

    /**
     * 批量删除教师考核结果
     *
     * @param Ids 需要删除的教师考核结果主键
     * @return 结果
     */
    @Override
    public int deleteAssessmentResultByIds(Long[] Ids) {
        return assessmentResultMapper.deleteAssessmentResultByIds(Ids);
    }

    /**
     * 删除教师考核结果信息
     *
     * @param Id 教师考核结果主键
     * @return 结果
     */
    @Override
    public int deleteAssessmentResultById(Long Id) {
        return assessmentResultMapper.deleteAssessmentResultById(Id);
    }

    @Override
    public int updata2(List<AssessmentResult> resultList) {
        for (AssessmentResult result : resultList) {
            long l = result.getAssessmentScore() + result.getBonusPoints() - result.getMinusPoints();
            result.setLastScore(l);
            assessmentResultMapper.updateAssessmentResult(result);
        }


        return 1;
    }

//    @Override
//    public int updata2(AssessmentResult assessmentResult) {
//        long l = assessmentResult.getAssessmentScore() + assessmentResult.getBonusPoints() - assessmentResult.getMinusPoints();
//
//        assessmentResult.setLastScore(l);
//        assessmentResultMapper.updateAssessmentResult(assessmentResult);
//
//
//        return 0;
//    }
}
